﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nini.Config;
using System.Windows.Forms;


namespace PowerControl
{
    class ServicesManager : LazySingleton<ServicesManager>
    {
        private SortedDictionary<String,Service> services;
        
        private ServicesManager() { }

        public void Init(string ConfigFile)
        {
            services = new SortedDictionary<string,Service>();
            IniConfigSource source = new IniConfigSource(Application.StartupPath+"\\config\\services.ini");
            for (int i = 0; i < source.Configs.Count; ++i)
            {
                Service srv = new Service();
                srv.CIRTargetDownlink = source.Configs[i].GetDouble("cirdown");
                srv.CIRTargetUplink = source.Configs[i].GetDouble("cirup");
                srv.Name = source.Configs[i].Name;
                services.Add(source.Configs[i].Name, srv);
            }
        }

        public Service getService(string Name)
        {
            return services[Name];
        }
    }
}
